<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0;
            padding: 0;
            border:none;
            list-style: none;
        }
        img{
            vertical-align: top;
        }

        body{
            background-color: #000;
        }

        #slider{
            width: 1200px;
            height: 460px;
            margin: 100px auto;

            position: relative;
            /*background-color: red;*/
        }

        #slider li{
            position: absolute;
            left: 200px;
            top:0;
        }

        #slider li img{
            width: 100%;
            height: 100%;
        }

        .slider_ctl_prev, .slider_ctl_next{
            width: 76px;
            height: 112px;
            position: absolute;
            top: 50%;
            margin-top: -56px;
            z-index: 99;
        }

        #slider_ctl{
            opacity: 0;
        }

        .slider_ctl_prev{
            background: url("images/prev.png") no-repeat;
            left: 0;
        }

        .slider_ctl_next{
            background: url("images/next.png") no-repeat;
            right: 0;
        }
    </style>
</head>
<body>
    <div id="slider">
        <ul id="slider_main">
            <li><img src="images/slidepic1.jpg" alt=""></li>
            <li><img src="images/slidepic2.jpg" alt=""></li>
            <li><img src="images/slidepic3.jpg" alt=""></li>
            <li><img src="images/slidepic4.jpg" alt=""></li>
            <li><img src="images/slidepic5.jpg" alt=""></li>
        </ul>
        <div id="slider_ctl">
            <span class="slider_ctl_prev"></span>
            <span class="slider_ctl_next"></span>
        </div>
    </div>
<script src="js/myFunc.js"></script>
<script>
    window.onload = function () {
        // 1. 获取需要的标签
        var slider = $("slider");
        var slider_main = $("slider_main");
        var allLis = slider_main.children;
        var slider_ctl = $("slider_ctl");

        var flag = true;

        // 2. 设置指示器的显示和隐藏
        slider.onmouseover = function () {
            buffer(slider_ctl, {"opacity": 1});
        };

        slider.onmouseout = function () {
            buffer(slider_ctl, {"opacity": 0});
        };

        // 3. 定位
        var json = [
            {   //  1
                width:400,
                top:20,
                left:50,
                opacity:0.2,
                zIndex:2
            },
            {  // 2
                width:600,
                top:70,
                left:0,
                opacity:0.8,
                zIndex:3
            },
            {   // 3
                width:800,
                top:100,
                left:200,
                opacity:1,
                zIndex:4
            },
            {  // 4
                width:600,
                top:70,
                left:600,
                opacity:0.8,
                zIndex:3
            },
            {   //5
                width:400,
                top:20,
                left:750,
                opacity:0.2,
                zIndex:2
            }
        ];
        for(var i=0; i<json.length; i++){
            buffer(allLis[i], json[i]);
        }

        //4. 监听点击
        for(var j=0; j<slider_ctl.children.length; j++){
            var item = slider_ctl.children[j];
            item.onmousedown = function () {
                if(this.className === "slider_ctl_prev"){ // 左边
                    json.push(json.shift());
                }else { // 右边
                    json.unshift(json.pop());
                }
                // 重新布局
                for(var i=0; i<json.length; i++){
                    buffer(allLis[i], json[i]);
                }
            }
        }

    }
</script>
</body>
</html>